package javabasic.threads.cunqian;

public class AddTask implements Runnable{
    private BankCount bankCount;

    public AddTask(BankCount bankCount) {
        this.bankCount = bankCount;
    }

    @Override
    public void run() {
        for (int i = 0; i < 3; i++) {
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            bankCount.add();
            System.out.println(Thread.currentThread().getName()+"第"+i+"次存钱100，账户余额："+bankCount.getSum());
        }
    }
}
